package com.iocaop.uaa.validation;

import com.iocaop.uaa.annotation.PasswordMatch;
import com.iocaop.uaa.domain.dto.UserDto;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class PasswordMatchValidator implements ConstraintValidator<PasswordMatch, UserDto> {
    @Override public void initialize(PasswordMatch constraintAnnotation) {
    }

    @Override public boolean isValid(UserDto userDto, ConstraintValidatorContext constraintValidatorContext) {
        // 比较密码和确认密码字段是否一致
        boolean b = userDto.getMatchPassword().equals(userDto.getPassword());
        return b;
    }
}
